﻿Imports System.Security.Cryptography
Imports System.Text
Public Class DecryptConnection

    Private Shared DES As New TripleDESCryptoServiceProvider
    Private Shared MD5 As New MD5CryptoServiceProvider
    Public Shared Function MD5Hash(vaule As String) As Byte()
        Return MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(vaule))

    End Function
    Public Shared Function DecryptCN()
        Return DecryptConnection.Decrypt(My.Settings.ConnectionString, "Steady Henry")
    End Function

    'now we need to create Decrypt function
    Public Shared Function Decrypt(EncryptedString As String, key As String) As String
        DES.Key = MD5Hash(key)
        DES.Mode = CipherMode.ECB
        Dim buffer As Byte() = Convert.FromBase64String(EncryptedString)
        Return ASCIIEncoding.ASCII.GetString(DES.CreateDecryptor().TransformFinalBlock(buffer, 0, buffer.Length))
        'done!!! lest's see
    End Function
End Class
